<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use app\common\model\Role;
use think\Session;
use app\common\model\Users_role;

class User extends Common
{
    //Users_role 关联表
    //Role 用户表
    public function index(Role $role, Request $request)
    {

        $user = $role->where('uid', '=', Session::get('user.id'))->find();
//        p(Session::get('user.id'));
        //
//        p($_POST);
        if (IS_POST) {
            $data = ['uid' => Session::get('user.id'),
                'username' => $request->post('username'),
                'email' => $request->post('email'),
                'phone' => $request->post('phone'),
                'qq' => $request->post('qq'),
                'brief' => $request->post('brief')];


            if ($user) {


                $role->where('uid', '=', Session::get('user.id'))->update($data);

                $this->success('修改成功', '/user');


            } else {
                $role->save($data);


                $this->success('保存成功', '/user');

            }


        }
        return view('', compact('user'));
    }


    //admin管理权限

    public
    function power()
    {

        return view();
    }


}
